Skip to content

Encode a ranked accumulator's sortBy as one document (2.5.x) - #4584

Merged
evanchooly merged 1 commit into
2.5.xfrom
backport-ranked-sortby-2.5
Nov 23, 2026
Merged

evanchooly merged 1 commit into
2.5.xfrom
backport-ranked-sortby-2.5

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Backport of #4571 to 2.5.x.

Problem

$top, $bottom, $topN and $bottomN with more than one sort key encoded sortBy as an array of one-key documents, [{score: -1}, {player: 1}]. The server takes one document whose keys are in priority order, {score: -1, player: 1}, and rejects the array. A single sort key worked.

Change

RankedResultsExpression and NRankedResultsExpression always write sortBy as one document. The sort orders stay Int64, as 2.5 writes them; the Int32 change is 3.0 only.

Verification

  • New TestRankedSortBy: topN and bottom with two keys encode one ordered document, and the server accepts the pipeline and breaks a tie on the second key. It fails without the fix.
  • TestTopN, TestBottomN, TestFirstN and TestLastN still pass.

$top, $bottom, $topN and $bottomN with more than one sort key wrote
sortBy as an array of one-key documents, which the server rejects; it
takes one document whose keys are in priority order. Backport of #4571.
@evanchooly evanchooly added this to the 2.5.4 milestone Nov 23, 2026
@evanchooly
evanchooly merged commit dc82784 into 2.5.x Nov 23, 2026
46 checks passed
@evanchooly
evanchooly deleted the backport-ranked-sortby-2.5 branch November 23, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant